#ifndef CAFFEINE_UTILITY_FACTORY_HPP
#define CAFFEINE_UTILITY_FACTORY_HPP

#include "Common.hpp"
#include "Utility/Creator.hpp"

#include <map>

namespace Utility
{
	template< typename Base >
	class Factory
	{
	public:
		Factory( void )
		{
		}

		virtual ~Factory( void )
		{
		}

		virtual void Register( const std::string type, Utility::BaseCreator< Base > *ctor )
		{
			types[ type ] = ctor;
		}

		virtual Base *Create( const std::string type )
		{
			return types[ type ]->Create();
		}

		virtual BaseCreator< Base > *GetCreator( const std::string type )
		{
			return types[ type ];
		}
	protected:
		std::map< std::string, Utility::BaseCreator< Base > * > types;
	};
}

#endif //CAFFEINE_UTILITY_FACTORY_HPP